home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / AppsToGo / AppsToGo.src / DTS.StyleChat / App.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-18  |  4.5 KB  |  119 lines  |  [TEXT/MPS ]

  1. #ifndef __APPHEADER__
  2. #define __APPHEADER__
  3.  
  4. #ifndef __DTSLib__
  5. #include "DTS.Lib.h"
  6. #endif
  7.  
  8. #ifndef __PRINTING__
  9. #include <Printing.h>
  10. #endif
  11.  
  12. #ifndef __TREEOBJ__
  13. #include <TreeObj.h>
  14. #endif
  15.  
  16. /********/
  17.  
  18. #define VH_VERSION  1                /* True means to include ViewHierarchy window.             */
  19. #define DEV_VERSION 1                /* True means allow option-cmd.period escape from dialogs. */
  20.  
  21. /* If you are unfamiliar with programming with the DTS.framework, you probably want to
  22. ** read the file "=How to write your app", which is found at the same level as the
  23. ** directory for this project. */
  24.  
  25. typedef struct {
  26.     DocHeaderInfo    fhInfo;        /* Doc header info (version, print record, window loc. ) */
  27.     TreeObjHndl        root;
  28.                                 /***** Start of custom file info. *****/
  29.     Handle            textHndl;    /* Temporarily holds opened document text.
  30.                                 ** The document is first read in, and then a
  31.                                 ** window is created for it.  Until the window
  32.                                 ** is created, we can't have a TextEdit control.
  33.                                 ** This field holds the text that was read in
  34.                                 ** when the file was opened.  It is disposed of
  35.                                 ** after the TextEdit control is created and
  36.                                 ** holds the document text. */
  37.     StScrpHandle    textStyl;    /* Same story as textHndl. */
  38.  
  39.     TEHandle        inBox;        /* TextEdit in-box.  */
  40.     TEHandle        outBox;        /* TextEdit out-box. */
  41. } TheDoc;
  42.  
  43. /* Below is the master document structure.  All DTS.framework documents use this structure.
  44. ** For each unique document type, union in a sub-structure for the document-specific
  45. ** information.  In the case of AppWannabe, there is only one known document type initially.
  46. ** The structure for this document type is defined just above.  Even though there is only one,
  47. ** it is still placed in a union.  This allows easy addition of additional document types later.
  48. ** Given a FileRec handle called frHndl, a sample dereference to the inBox field would look like:
  49. **     inBox = (*frHndl)->d.doc.inBox;
  50. **
  51. ** The fileState and connect fields are expected and managed by DTS.framework.  Also, the
  52. ** first two fields in the app-specific portion of the document are expected, namely
  53. ** the fhInfo and root fields. */
  54.  
  55. typedef struct FileRec {
  56.     FileStateRec    fileState;        /* DTS.Lib expects this structure here. */
  57.     ConnectRec        connect;        /* DTS.Lib expects this structure here. */
  58.     union {
  59.         TheDoc    doc;                /* Union in each document type here. */
  60.     } d;
  61. } FileRec;
  62.  
  63. /* Below is the definition of the hierarchical document's root object.  If you are using
  64. ** the hierarchical document package TreeObj, then you will need at least this object.
  65. ** TreeObj expects the first two fields to be undo and frHndl, as shown below.  You can
  66. ** add fields after these two fields.  If you use TreeObj, the root object and all of its
  67. ** children are automatically saved and read from disk.
  68. ** Note that the definition for the root object includes a prototype.  Each object is
  69. ** automatically called by DTS.framework at appropriate times.  The prototype defines the
  70. ** function that will be called for this object.  See the files "=How to write your app"
  71. ** and "=Using TreeObj.c" for more information. */
  72.  
  73. long    TRootObj(TreeObjHndl hndl, short message, long data);
  74. typedef struct {
  75.     TreeObjHndl    undo;        /* This structure may be added to, but */
  76.     FileRecHndl    frHndl;        /* these two first fields must remain. */
  77. } RootObj;
  78.  
  79. /********/
  80.  
  81. #define kMaxNumUndos  64
  82. #define kNumSaveUndos 8
  83.  
  84. #define kNumTreeObjs   16        /* Minimum number of objects is 16. */
  85.  
  86. #define mDerefRoot(hndl)     ((RootObj*)((*hndl) + 1))
  87.  
  88. /********/
  89.  
  90. /* These values are passed to the DTS.framework function Initialize(). */
  91. #define kMinHeap    64 * 1024        /* Needs at least 64k of heap space. */
  92. #define kMinSpace    64 * 1024        /* Needs this much after calling PurgeSpace. */
  93.  
  94.  
  95. #define kwAppWindow    (kwGrowIcon | kwHScrollLessGrow | kwVScrollLessGrow | kwVisible | kwOpenAtOldLoc)
  96.     /* Main application window has growIcon, horizontal and vertical document scrollbars,
  97.     ** is initially visible, and if the document is saved, it will open at the location
  98.     ** it was last closed at. */
  99.  
  100. #define keyAppMessage      'KMSG'         /* Custom Apple Event definitions. */
  101. #define typeAppMessage     'KMSG'
  102. #define typeTextMessage    'KTXT'
  103. #define typeStylMessage    'KSTL'
  104.  
  105. #define kDisconnectMssg    0
  106. #define kTextMssg        1
  107. #define kStylMssg        2
  108.  
  109. #define kStylResType    'KSTL'
  110. #define kStylResID        20000
  111.  
  112. #define kVersion        100        /* Document versions, not application versions. */
  113. #define kMinVersion        100
  114. #define kMaxVersion        100
  115.  
  116. #define kMaxNumWindows        65535        /* No limit on the number of windows. */
  117.  
  118. #endif
  119.